package com.sto.stoapp.activity.administrator.hardware;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.view.KeyEvent;
import android.widget.Toast;

import com.sto.stoapp.StoApplication;
import com.sto.stoapp.activity.R;
import com.sto.stoapp.broadcast.HomeBroadAction;
import com.sto.stoapp.widget.StoHomeActivity;

import sto.android.app.StoPdaKeyEvent;

/**
 * 语音测试
 * 
 * @author mgf
 * 
 */
public class AdminVoiceTestActivity extends StoHomeActivity {
	
	private TelephonyManager tm;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.admin_voice_test);
		this.setTitleBottom(R.string.voice_test,
				HomeBroadAction.ADMINISTRATOR_BROAD);
		// 取得相关系统服务
		tm = (TelephonyManager) this.getSystemService(TELEPHONY_SERVICE);
	}
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (StoApplication.getStoJni().getEventFuction(keyCode) == StoPdaKeyEvent.KEYCODE_DPAD_CENTER) {
			if (tm.getSimState() != TelephonyManager.SIM_STATE_READY) {
				Toast.makeText(this,
						R.string.no_sim_card, Toast.LENGTH_LONG).show();
				return super.onKeyDown(keyCode, event);
			}
			Intent tn = new Intent("android.intent.action.CALL", Uri
					.parse("tel:" + "10086"));
			startActivity(tn);
		}
		return super.onKeyDown(keyCode, event);
	}
}
